{layout name="main"/}
<div class="wrapper wrapper-content animated fadeInUp">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">

                <div class="ibox-title">
                    <h5>添加充值</h5>

                </div>
                <div class="ibox-content">
                    <form method="post" action="" class="form-horizontal m-t" id="cz">

                        <div class="form-group">
                            <label class="col-sm-3 control-label">充值会员编号 * </label>
                            <div class="col-sm-5">
                                <input type="text" placeholder="请输入会员编号"  class="form-control" name="user_uniid" value="">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">充值类型 * </label>
                            <div class="col-sm-5">
                                <select class="form-control" name="cash_type">
                                    <option value="0">请选择</option>
                                    <option value="财富币">财富币</option>
                                    <option value="报单币">报单币</option>

                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">充值金额 * </label>
                            <div class="col-sm-5">

                                <div class="input-group m-b"><span class="input-group-addon">&yen;</span>
                                    <input type="text" name='cash_value' class="form-control"> <span class="input-group-addon">.00</span>

                                </div>
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 要减少币值，输入负金额即可</span>

                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary"  type="button"  onclick='add()'>确认充值</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">

                <div class="ibox-title">
                    <h5>充值列表</h5>

                </div>

                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-sm-5">
                            <div class="input-daterange input-group" id="datepicker">
                                <input type="text" class="input-sm form-control" name="startdate" id="startdate" placeholder="开始时间" value="{$startdate}" />
                                <span class="input-group-addon">到</span>
                                <input type="text" class="input-sm form-control" name="enddate" id="enddate" placeholder="结束时间" value="{$enddate}" />
                            </div>
                        </div>
                        <div class="col-sm-7">
                            <div class="input-group">
                                <input type="text" placeholder="搜索(会员编号,会员昵称)" class="input-sm form-control" name=keyword value="{$keyword}"> <span class="input-group-btn">
                                    <button type="button" class="btn btn-sm btn-primary" onclick="search()">搜索</button> </span>
                            </div>
                        </div>
                    </div>
                    <div class="project-list">
                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable" id="DataTables_Table_0" aria-describedby="DataTables_Table_0_info">
                            <thead>
                                <tr role="row">

                                    <th  style="width: 15%;">会员编号</th>
                                    <th style="width: 15%;">会员昵称</th>
                                    <th  style="width: 10%;">充值金额</th>
                                    <th  style="width: 10%;">充值类型</th>
                                    <th  style="width: 20%;">充值时间</th>
                                    <th  style="width: 10%;">操作人</th>
                                    <th  style="width: 5%;">状态</th>

                                </tr>
                            </thead>

                            <!--                            <tbody><tr class="no-records-found"><td colspan="8">没有找到匹配的记录</td></tr></tbody>-->

                            <tbody>
                                {:table_empty_list($list,'暂无数据!',7)}

                                {volist name="list" id="vo"}

                                <tr class="gradeA odd">

                                    <td class=" ">{$vo->target_user->user_uniid}</td>
                                    <td class=" ">{$vo->target_user->user_name}</td>
                                    <td class="center ">{$vo->cash_value}</td>
                                    <td class="center ">{$vo->cash_type}</td>
                                    <td class="center ">{$vo->confirm_time}</td>
                                    <td class="center ">{$vo->confirmed_user->user_name}</td>
                                    <td class="center"><span class="badge badge-primary">{$vo->cash_flow_status}</span></td>

                                </tr>
                                {/volist}
                                <!--                                <tr class="gradeA even">
                                                                    <td class=" ">OKD001</td>
                                                                    <td class=" ">徐军0791</td>
                                                                    <td class="center ">2000</td>
                                                                    <td class="center ">报单币</td>
                                                                    <td class="center ">2016年3月3日</td>
                                                                    <td class="center ">admin</td>
                                                                    <td class="center"><span class="badge badge-primary">已确认</span></td>
                                                                </tr>-->
                            </tbody>

                        </table>
                        <!--                        <div class="row">
                                                    <div class="col-sm-6 m-t-sm">
                                                        <button class="btn btn-primary btn-xs" id="selectAll" onclick="deletearticle(1)"><i class="fa fa-check"></i> 全选 </button>
                                                        <button class="btn btn-warning btn-xs" id="deleteAll" onclick="deletearticle(1)"><i class="fa fa-trash"></i> 批量删除 </button>
                                                    </div>
                                                </div>-->
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="dataTables_info" id="DataTables_Table_0_info" role="alert" aria-live="polite" aria-relevant="all">
                                    每页显示 {:getPageSize()} 项，共 {$list->toArray()['total']} 项</div></div>
                            <div class="col-sm-6">
                                <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                    {$list->render()}

                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <script>
                $(".input-daterange").datepicker({keyboardNavigation: !1, forceParse: !1, autoclose: !0});
                //充值
                function add() {

                    var articledata = $("#cz").serialize();
                    post({
                        url: "{:url('/admin/Recharge/add')}",
                        data: articledata,
                        success: function (res) {
                            swal({
                                title: '成功',
                                text: res.message,
                                type: "success"
                            }, function () {
                                reload();
                            });
                        },
                        error: function (error) {
                            swal("错误", JSON.parse(error.responseText).message, "error");
                        }
                    });

                }
                function search() {
                    var url = "{:url('admin/Recharge/showlist', [],'')}";
                    var startdate = $("#startdate").val();
                    var enddate = $("#enddate").val();
                    if (startdate != "") {
                        url = url + "/startdate/" + startdate;
                    }
                    if (enddate != "") {
                        url = url + "/enddate/" + enddate;
                    }
                    var keyword = $("input[name=keyword]").val();
                    if (keyword != "") {
                        url = url + "?keyword=" + keyword;
                    }
                    toUrl(url);
                }

            </script>
